Remove @codingStandardsIgnore from long lines
[lhc/web/wiklou.git] / includes / shell / Shell.php
index c293ff2..604c96a 100644 (file)
@@ -22,6 +22,8 @@
 
 namespace MediaWiki\Shell;
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Executes shell commands
  *
@@ -35,14 +37,15 @@ namespace MediaWiki\Shell;
  *
  *  ... = $result->getExitCode();
  *  ... = $result->getStdout();
+ *  ... = $result->getStderr();
  */
 class Shell {
 
        /**
-        * Returns a new instance of this class
+        * Returns a new instance of Command class
         *
-        * @param string|string[] $command If string, a properly shell-escaped command line,
-        *   or an array of unescaped arguments, in which case each value will be escaped
+        * @param string|string[] $command String or array of strings representing the command to
+        * be executed, each value will be escaped.
         *   Example:   [ 'convert', '-font', 'font name' ] would produce "'convert' '-font' 'font name'"
         * @return Command
         */
@@ -53,7 +56,10 @@ class Shell {
                        // treat it as a list of arguments
                        $args = reset( $args );
                }
-               $command = new Command();
+               $command = MediaWikiServices::getInstance()
+                       ->getShellCommandFactory()
+                       ->create();
+
                return $command->params( $args );
        }
 
@@ -107,14 +113,12 @@ class Shell {
 
                        if ( wfIsWindows() ) {
                                // Escaping for an MSVC-style command line parser and CMD.EXE
-                               // @codingStandardsIgnoreStart For long URLs
                                // Refs:
                                //  * https://web.archive.org/web/20020708081031/http://mailman.lyra.org/pipermail/scite-interest/2002-March/000436.html
                                //  * https://technet.microsoft.com/en-us/library/cc723564.aspx
                                //  * T15518
                                //  * CR r63214
                                // Double the backslashes before any double quotes. Escape the double quotes.
-                               // @codingStandardsIgnoreEnd
                                $tokens = preg_split( '/(\\\\*")/', $arg, -1, PREG_SPLIT_DELIM_CAPTURE );
                                $arg = '';
                                $iteration = 0;